package demo.game.chess.common;

public class CastlingException extends MoveException {

	public static enum EnumCastlingExceptionKind {
		king_already_moved, rook_already_moved, king_in_check, prevent_by_attack
	}

	private ChessMove preventingAttack;

	private final EnumCastlingExceptionKind kind;

	private AbstractChessPiece attackingPiece;

	public CastlingException(final ChessMove invalidMove,
			final AbstractChessPiece attackingPiece,
			final ChessMove preventingAttack) {
		super(invalidMove, EnumCastlingExceptionKind.prevent_by_attack + ": "
				+ preventingAttack);
		this.kind = EnumCastlingExceptionKind.prevent_by_attack;
		this.attackingPiece = attackingPiece;
		this.preventingAttack = preventingAttack;
	}

	public CastlingException(final ChessMove invalidMove,
			final EnumCastlingExceptionKind kind) {
		super(invalidMove, kind.name());

		this.kind = kind;
	}

	public AbstractChessPiece getAttackingPiece() {
		return this.attackingPiece;
	}

	public EnumCastlingExceptionKind getKind() {
		return this.kind;
	}

	public ChessMove getPreventingAttack() {
		return this.preventingAttack;
	}

}
